package com.wf.controller;

import com.wf.domain.PropertyItem;
import com.wf.service.PropertyItemService;
import com.wf.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: zhiyu
 * @Date:9:56  b
 * @DESC:
 */
@Api("缴费项管理控制层")
@CrossOrigin
@RestController
public class PropertyController {
    @Autowired
    private PropertyItemService propertyItemService;
    @GetMapping("/propertyItemList")
    @ApiOperation("查询所有缴费项")
    public Result selectPropertyItemList(){
        List<PropertyItem> list = propertyItemService.list();
        return Result.success(list);
    }
    @PostMapping("/addItem")
    @ApiOperation("添加缴费项")
    public Result addPropertyItem(@RequestBody PropertyItem propertyItem){
        System.out.println("propertyItem = " + propertyItem);
        boolean save = propertyItemService.save(propertyItem);
        return Result.success(save);
    }
    @ApiOperation("更新缴费项信息")
    @PutMapping("/updateItem")
    public Result updateItemById(@RequestBody PropertyItem propertyItem){
        boolean b = propertyItemService.updateById(propertyItem);
        return Result.success(b);
    }
    @PutMapping("/deleteItem")
    @ApiOperation("删除缴费项")
    public Result deleteItem(@RequestBody PropertyItem propertyItem){
        propertyItem.setIsDelete(1);
        boolean b = propertyItemService.updateById(propertyItem);
        return Result.success(b);
    }
}
